package playnsimple.core.graphics;

import static playn.core.PlayN.graphics;

import org.jbox2d.common.Vec2;

import playn.core.Color;
import playn.core.GroupLayer;

public class GraphicsApi {
    
    // colors
    public static final Integer RED = Color.rgb(255, 0, 0);
    public static final Integer GREEN = Color.rgb(0, 255, 0);
    public static final Integer YELLOW = Color.rgb(228, 228, 0);
    public static final Integer BLUE = Color.rgb(0, 0, 255); 
    public static final Integer BLACK = Color.rgb(0, 0, 0);
    public static final Integer WHITE = Color.rgb(255, 255, 255);
    public static final Integer DARKGRAY = Color.rgb(32, 32, 32);
    
    // fonts
    public static final String SANS_SERIF = "Sans serif";
    
    
    /*
     * World/Screen Conversions
     */    
    public static Vec2 worldToScreen(Vec2 pt) {
        return new Vec2(worldToScreenX(pt.x), worldToScreenY(pt.y));
    }
    
    public static float worldToScreenX(Number x) {
        Vec2 screenCenter = getDisplayCenter();
        return screenCenter.x + x.floatValue();
    }

    public static float worldToScreenY(Number y) {
        Vec2 screenCenter = getDisplayCenter();
        return screenCenter.y - y.floatValue();
    }
    
    
    /*
     * Display / RootLayer Methods
     */
    public static int getDisplayWidth() {
        return graphics().width();
    }

    public static int getDisplayHeight() {
        return graphics().height();
    }

    public static Vec2 getDisplaySize() {
        return new Vec2(getDisplayWidth(), getDisplayHeight());
    }

    public static Vec2 getDisplayCenter() {
        Vec2 displaySize = getDisplaySize();
        return displaySize.mul(0.5f);
    }
}
